using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SavePoint : MonoBehaviour
{
    private Vector2 position;
    private bool isSaved = false;
    // Start is called before the first frame update
    void Start()
    {
        position = transform.position;
    }
    
    public Vector2 GetPosition()
    {
        return position;
    }
    public void BecameRealSavePoint()
    {

        if(isSaved == false)
        {
            isSaved = true;
            StartCoroutine(ChangeColor(new Color(250f/255f, 218f/255f, 43f/255f, 1f)));
        }
    }

    IEnumerator ChangeColor(Color color)
    {
        SpriteRenderer sr = GetComponent<SpriteRenderer>();
        Color deltaColor = color - sr.color ;
        float time = 0;
        while (time < 0.5f)
        {
            transform.position = transform.position - new Vector3( 0, Time.deltaTime,0);
            time += Time.deltaTime;
            sr.color += deltaColor * ( Time.deltaTime / 0.5f);
            yield return null;
        }
        { sr.color = color; }
    }
}
